//
//  ContentView.swift
//  XQSwiftUIDemo
//
//  Created by WXQ on 2019/11/12.
//  Copyright © 2019 WXQ. All rights reserved.
//

import SwiftUI

struct ContentView: View {
    
    @State var selection = 0
    
    var body: some View {
        
        TabView(selection: $selection, content: {
            NavigationView.init(content: {
                XQHomeView()
            })
                .tabItem { self.tabbarItem(text: "首页", image: "house") }
                .tag(0)
            
            NavigationView.init(content: {
                XQAnimationOneView()
            })
                .tabItem { self.tabbarItem(text: "Discover", image: "sun.min") }
                .tag(1)
            
            NavigationView.init(content: {
                Text("asd")
            })
                .tabItem { self.tabbarItem(text: "Discover", image: "pencil") }
                .tag(2)
            
            NavigationView.init(content: {
                Text("asd")
            })
                .tabItem { self.tabbarItem(text: "Discover", image: "wifi") }
                .tag(3)
        })
            .statusBar(hidden: self.selection == 3 ? true : false)
        
    }
    
    func tabbarItem(text: String, image: String) -> some View {
        //        VStack {
        //            Image(systemName: image)
        ////                .imageScale(.large)
        ////                .frame(width: 40, height: 40, alignment: .top)
        //            Text(text)
        //        }
        
        VStack {
            Image(systemName: image)
                .imageScale(.large)
                
            Text(text)
                .foregroundColor(Color.orange)
        }
            .hidden()
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
